package com.cg.design.graphicdesignpattern.adapter;

import org.junit.Test;

import java.io.IOException;

/**
 * @program: LeetCode->AdapterTest
 * @description: 测试类
 * @author: cg
 * @create: 2022-03-17 21:30
 **/
public class AdapterTest {

    @Test
    public void testAdapter() {
        // 类适配器模式（使用继承的适配器）
        Print print1 = new PrintBanner1("Hello");
        print1.printWeak();
        print1.printStrong();
        // 对象适配器模式（使用委托的适配器）
        Print print2 = new PrintBanner2("World");
        print2.printWeak();
        print2.printStrong();
        FileIO file = new FileProperties();
        try {
            file.readFromFile("src\\com\\cg\\design\\adapter\\file.txt");
            file.setValue("year", "2022");
            file.setValue("month", "3");
            file.setValue("day", "17");
            file.writeToFile("src\\com\\cg\\design\\adapter\\newfile.txt");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
